package com.btpj.module_search.data.remote

import com.btpj.jetpack.http.RetrofitClient
import com.btpj.jetpack.http.api.BaseRepository
import com.btpj.jetpack.entity.ApiResult
import com.btpj.module_search.data.entity.HotKeyModel
import com.btpj.module_search.data.entity.SearchResultModel

class SearchRepository(private val retrofitClient: RetrofitClient) : BaseRepository() {

    suspend fun getHotKey(): ApiResult<MutableList<HotKeyModel>> {
        return callRequest {
            handleResponse(retrofitClient.create(SearchApi::class.java).getHotKey())
        }
    }

    suspend fun search(page: Int, key: String): ApiResult<SearchResultModel> {
        return callRequest {
            handleResponse(retrofitClient.create(SearchApi::class.java).search(page, key))
        }
    }
}